<template>
    <div class="iii">

        <div class="intu">
            <el-card style="width: 800px;text-align: center;position:absolute;top: 50%;left: 50%;transform: translate(-50%,-50%)" class="card">
                <div slot="header" >
                    <h4>注册</h4>
                </div>
                <div>
                    <el-form :model="user" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" inline>
                        <el-form-item label="账号" prop="acct" placeholder="请输入账号">
                            <el-input v-model="user.acct"   type="text" ></el-input>
                        </el-form-item>
                        <br>
                        <el-form-item label="密码" prop="paw" placeholder="请输入密码">
                            <el-input v-model="user.paw"  type="password" ></el-input>
                        </el-form-item>
                        <br>
                        <el-form-item label="姓名" prop="name" placeholder="请输入姓名">
                            <el-input v-model="user.name"  type="text"></el-input>
                        </el-form-item>
                        <br>
                        <el-form-item label="电话号码" prop="phone" placeholder="请输入手机号">
                            <el-input v-model="user.phone"  type="text"></el-input>
                        </el-form-item>
                        <br>
<!--                        <el-form-item label="验证码"  prop="code" placeholder="请输入验证码">-->
<!--                            <el-input v-model="user.code"  style="width: 150px;"  type="text"></el-input><el-button style="background-color: #66b1ff;display: inline-block">发送验证码</el-button>-->
<!--                        </el-form-item>-->
<!--                        <br>-->
                        <el-form-item>
                            <el-button @click="submitForm('ruleForm')" type="primary">注册</el-button>
                            <el-button @click="$router.push('/login')" type="text">已有账号？去登录</el-button>
                        </el-form-item>

                    </el-form>
                </div>
            </el-card>
        </div>

    </div>

</template>

<script>

    export default {
        name: "rigest",
        data() {
            return {
                user: {},
                checked: false,
                buttonName: "发送验证码",
                isDisabled: false,
                time: 60,
                code: '',
                code1: '',
                rules:{
                    acct:[
                        {required: true, message: '请输入账号', trigger: 'blur'},
                        {min: 3, max: 11, message: '长度在 3 到 11 个字符', trigger: 'blur'}
                    ],
                    paw:[
                        {required: true, message: '请输入密码', trigger: 'blur'},
                        {min: 3, max: 11, message: '长度在 3 到 11 个字符', trigger: 'blur'}
                    ],
                    name:[
                        {required: true, message: '请输入姓名', trigger: 'blur'},
                        {min: 3, max: 11, message: '长度在 3 到 11 个字符', trigger: 'blur'}
                    ],
                    phone:[
                        {required: true, message: '请输入电话', trigger: 'blur'},
                        {min: 11, max: 11, message: '长度在11位数字', trigger: 'blur'}
                    ],
                    sex:[
                        {required: true, message: '请输入性别', trigger: 'blur'},
                        {min: 1, max: 11, message: '长度在11位数字', trigger: 'blur'}
                    ],

                }
            }
        },

        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.rigte();
                    } else {
                        return false;
                    }
                });
            },
            rigte() {

                this.$axios.post('/api/user/register', this.user).then((res) => {
                    if (res.data.status === 1) {
                        this.$message.success(res.data.msg);
                        this.$router.push('/login');
                    } else {
                        this.$message.error(res.data.msg);
                    }
                })
            },
            handleSelect(key, keyPath) {
                console.log(key, keyPath);
            }
        }
    }
</script>


<style>
        .iii{
            background-image: url("https://img0.baidu.com/it/u=4042598855,3530957399&fm=26&fmt=auto&gp=0.jpg");
            position:fixed;
            top: 0;
            left: 0;
            width:100%;
            height:100%;
            min-width: 1000px;
            z-index:-10;
            zoom: 1;
            background-color: #fff;
            background-size: cover;
            -webkit-background-size: cover;
            -o-background-size: cover;
            background-position: center 0;

        }
</style>